<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Pepr3D: D:/Home/MFF/1-Mgr/projekt/pepr3d/src/geometry/ColorManager.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="pepr3d_icon.svg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Pepr3D
   &#160;<span id="projectnumber">v1.0</span>
   </div>
   <div id="projectbrief">Pepr3D is a 3D graphics editor designed for FDM printing</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.15 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('_color_manager_8h_source.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">ColorManager.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &lt;cereal/archives/binary.hpp&gt;</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;cereal/types/vector.hpp&gt;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &lt;random&gt;</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &quot;cinder/Color.h&quot;</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;glm/glm.hpp&quot;</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &quot;peprassert.h&quot;</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#define PEPR3D_MAX_PALETTE_COLORS 16</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacepepr3d.html">pepr3d</a> {</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;</div><div class="line"><a name="l00016"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html">   16</a></span>&#160;<span class="keyword">class </span><a class="code" href="classpepr3d_1_1_color_manager.html">ColorManager</a> {</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;   <span class="keyword">public</span>:</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;    <span class="keyword">using</span> ColorMap = std::vector&lt;glm::vec4&gt;;</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;   <span class="keyword">private</span>:</div><div class="line"><a name="l00022"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">   22</a></span>&#160;    ColorMap <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>;</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">   25</a></span>&#160;    <span class="keywordtype">size_t</span> <a class="code" href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">mActiveColorIndex</a> = 0;</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    <span class="keyword">friend</span> <span class="keyword">class </span>cereal::access;</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;   <span class="keyword">public</span>:</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;    <a class="code" href="classpepr3d_1_1_color_manager.html">ColorManager</a>() {</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.push_back(static_cast&lt;glm::vec4&gt;(ci::ColorA::hex(0x017BDA)));</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.push_back(static_cast&lt;glm::vec4&gt;(ci::ColorA::hex(0xEB5757)));</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.push_back(static_cast&lt;glm::vec4&gt;(ci::ColorA::hex(0xF2994A)));</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.push_back(static_cast&lt;glm::vec4&gt;(ci::ColorA::hex(0x292E33)));</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;        P_ASSERT(<a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.size() &lt;= PEPR3D_MAX_PALETTE_COLORS);</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    }</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    <a class="code" href="classpepr3d_1_1_color_manager.html">ColorManager</a>(<span class="keyword">const</span> ColorMap::const_iterator start, <span class="keyword">const</span> ColorMap::const_iterator end) {</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#add375baf3a503d79d4922dbd360b62af">replaceColors</a>(start, end);</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    }</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    <span class="keyword">explicit</span> ColorManager(<span class="keyword">const</span> <span class="keywordtype">size_t</span> number) {</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;        generateColors(number, <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>);</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    }</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div><div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#aa6453cf533bb4bb251203bd599c48321">   47</a></span>&#160;    glm::vec4 <a class="code" href="classpepr3d_1_1_color_manager.html#aa6453cf533bb4bb251203bd599c48321">getColor</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> i)<span class="keyword"> const </span>{</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;        P_ASSERT(i &lt; <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.size());</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>[i];</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    }</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;</div><div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#a136ee5ee62632d6537377fccdc5ef9c6">   53</a></span>&#160;    <span class="keywordtype">size_t</span> <a class="code" href="classpepr3d_1_1_color_manager.html#a136ee5ee62632d6537377fccdc5ef9c6">size</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.size();</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    }</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;</div><div class="line"><a name="l00058"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#a439df566020a7f10221a4e4c3fd36e7d">   58</a></span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="classpepr3d_1_1_color_manager.html#a439df566020a7f10221a4e4c3fd36e7d">empty</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.empty();</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    }</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div><div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#adb8aeb957d6a1cd5a79ebc0e246f5ca7">   63</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classpepr3d_1_1_color_manager.html#adb8aeb957d6a1cd5a79ebc0e246f5ca7">clear</a>() {</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.clear();</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    }</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;</div><div class="line"><a name="l00068"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#a5ddc4ed221439f8b744b6d85b89127b3">   68</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classpepr3d_1_1_color_manager.html#a5ddc4ed221439f8b744b6d85b89127b3">addColor</a>(<span class="keyword">const</span> glm::vec4 newColor) {</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;        <span class="keywordflow">if</span>(<a class="code" href="classpepr3d_1_1_color_manager.html#a136ee5ee62632d6537377fccdc5ef9c6">size</a>() &lt; PEPR3D_MAX_PALETTE_COLORS) {</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;            <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.push_back(newColor);</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;        }</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;        P_ASSERT(<a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.size() &lt;= PEPR3D_MAX_PALETTE_COLORS);</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    }</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div><div class="line"><a name="l00076"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#a3f11321a8da932e4bf9f7d9a83ecc7f1">   76</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classpepr3d_1_1_color_manager.html#a3f11321a8da932e4bf9f7d9a83ecc7f1">setColor</a>(<span class="keyword">const</span> <span class="keywordtype">size_t</span> i, <span class="keyword">const</span> glm::vec4 newColor) {</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;        P_ASSERT(i &lt; <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.size());</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>[i] = newColor;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;    }</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;</div><div class="line"><a name="l00082"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#add375baf3a503d79d4922dbd360b62af">   82</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classpepr3d_1_1_color_manager.html#add375baf3a503d79d4922dbd360b62af">replaceColors</a>(<span class="keyword">const</span> ColorMap::const_iterator start, <span class="keyword">const</span> ColorMap::const_iterator end) {</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;        <span class="keyword">auto</span> it = start;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.clear();</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.reserve(std::min&lt;std::size_t&gt;(end - start, PEPR3D_MAX_PALETTE_COLORS));</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;        <span class="keywordflow">while</span>(it != end &amp;&amp; <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.size() &lt; PEPR3D_MAX_PALETTE_COLORS) {</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;            <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.push_back(*it);</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;            ++it;</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;        }</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;        <span class="keywordflow">if</span>(<a class="code" href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">mActiveColorIndex</a> &gt;= <a class="code" href="classpepr3d_1_1_color_manager.html#a136ee5ee62632d6537377fccdc5ef9c6">size</a>()) {</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;            <a class="code" href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">mActiveColorIndex</a> = <a class="code" href="classpepr3d_1_1_color_manager.html#a136ee5ee62632d6537377fccdc5ef9c6">size</a>() - 1;</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;        }</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    }</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;</div><div class="line"><a name="l00096"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#a2393992e48c2c6715ac33cb067d3dc75">   96</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classpepr3d_1_1_color_manager.html#a2393992e48c2c6715ac33cb067d3dc75">replaceColors</a>(<span class="keyword">const</span> ColorMap&amp; newColors) {</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a> = newColors;</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        <span class="keywordflow">if</span>(<a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.size() &gt; PEPR3D_MAX_PALETTE_COLORS) {</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;            <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>.resize(PEPR3D_MAX_PALETTE_COLORS);</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;        }</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;        <span class="keywordflow">if</span>(<a class="code" href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">mActiveColorIndex</a> &gt;= <a class="code" href="classpepr3d_1_1_color_manager.html#a136ee5ee62632d6537377fccdc5ef9c6">size</a>()) {</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;            <a class="code" href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">mActiveColorIndex</a> = <a class="code" href="classpepr3d_1_1_color_manager.html#a136ee5ee62632d6537377fccdc5ef9c6">size</a>() - 1;</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        }</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;    }</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;</div><div class="line"><a name="l00107"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#a3532df102b706a03bc0e23401c457e4f">  107</a></span>&#160;    <span class="keywordtype">size_t</span> <a class="code" href="classpepr3d_1_1_color_manager.html#a3532df102b706a03bc0e23401c457e4f">getActiveColorIndex</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">mActiveColorIndex</a>;</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    }</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;</div><div class="line"><a name="l00112"></a><span class="lineno"><a class="line" href="classpepr3d_1_1_color_manager.html#a81d621c28e948d1b3159dde1bcb73aea">  112</a></span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classpepr3d_1_1_color_manager.html#a81d621c28e948d1b3159dde1bcb73aea">setActiveColorIndex</a>(<span class="keywordtype">size_t</span> index) {</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;        <a class="code" href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">mActiveColorIndex</a> = std::min&lt;size_t&gt;(std::max&lt;size_t&gt;(index, 0), <a class="code" href="classpepr3d_1_1_color_manager.html#a136ee5ee62632d6537377fccdc5ef9c6">size</a>() - 1);</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;    }</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    glm::vec4 getActiveColor()<span class="keyword"> const </span>{</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>[<a class="code" href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">mActiveColorIndex</a>];</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;    }</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    ColorMap&amp; getColorMap() {</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>;</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    }</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    <span class="keyword">const</span> ColorMap&amp; getColorMap()<span class="keyword"> const </span>{</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>;</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;    }</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">void</span> generateColors(<span class="keyword">const</span> <span class="keywordtype">size_t</span> colorCount, std::vector&lt;glm::vec4&gt;&amp; outNewColors) {</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;        outNewColors.clear();</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;        outNewColors.reserve(colorCount);</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;        std::random_device rd;   <span class="comment">// Will be used to obtain a seed for the random number engine</span></div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;        std::mt19937 gen(rd());  <span class="comment">// Standard mersenne_twister_engine seeded with rd()</span></div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;        std::uniform_real_distribution&lt;&gt; randomGenHue(0.0, 1.0);</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;        std::uniform_real_distribution&lt;&gt; randomGenValue(0.6, 1.0);</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;        <span class="keyword">const</span> <span class="keywordtype">float</span> start = static_cast&lt;float&gt;(randomGenHue(gen));</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;        <span class="keywordflow">for</span>(<span class="keywordtype">size_t</span> i = 0; i &lt; colorCount; ++i) {</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;            <span class="keyword">const</span> <span class="keywordtype">float</span> added = start + static_cast&lt;float&gt;(i) / static_cast&lt;float&gt;(colorCount) * 0.7f;</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;            <span class="keywordtype">float</span> whole, fractional;</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;            fractional = std::modf(added, &amp;whole);</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;            ci::ColorA r = cinder::hsvToRgb(glm::vec4(fractional, 1, randomGenValue(gen), 1));</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;            outNewColors.emplace_back(r.r, r.g, r.b, 1);</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;        }</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    }</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;   <span class="keyword">private</span>:</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    <span class="keyword">template</span> &lt;<span class="keyword">class</span> Archive&gt;</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;    <span class="keywordtype">void</span> serialize(Archive&amp; ar) {</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;        ar(<a class="code" href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">mColorMap</a>);</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;        ar(<a class="code" href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">mActiveColorIndex</a>);</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    }</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;};</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;}  <span class="comment">// namespace pepr3d</span></div><div class="ttc" id="classpepr3d_1_1_color_manager_html_a3f11321a8da932e4bf9f7d9a83ecc7f1"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#a3f11321a8da932e4bf9f7d9a83ecc7f1">pepr3d::ColorManager::setColor</a></div><div class="ttdeci">void setColor(const size_t i, const glm::vec4 newColor)</div><div class="ttdoc">Set the i-th color to a new color.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:76</div></div>
<div class="ttc" id="namespacepepr3d_html"><div class="ttname"><a href="namespacepepr3d.html">pepr3d</a></div><div class="ttdoc">Fix for CGAL bugs in polygon with holes verification Contained in CGAL PR #3688, likely to be in 4....</div><div class="ttdef"><b>Definition:</b> CmdColorManager.h:9</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_a439df566020a7f10221a4e4c3fd36e7d"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#a439df566020a7f10221a4e4c3fd36e7d">pepr3d::ColorManager::empty</a></div><div class="ttdeci">bool empty() const</div><div class="ttdoc">Returns true iff no colors are currently used.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:58</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_a29706f2b1a4d4870f4d9398c4830f9ec"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#a29706f2b1a4d4870f4d9398c4830f9ec">pepr3d::ColorManager::mActiveColorIndex</a></div><div class="ttdeci">size_t mActiveColorIndex</div><div class="ttdoc">Index of a currently selected / active color.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:25</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_adb8aeb957d6a1cd5a79ebc0e246f5ca7"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#adb8aeb957d6a1cd5a79ebc0e246f5ca7">pepr3d::ColorManager::clear</a></div><div class="ttdeci">void clear()</div><div class="ttdoc">Clears all colors and becomes empty.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:63</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_aa6453cf533bb4bb251203bd599c48321"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#aa6453cf533bb4bb251203bd599c48321">pepr3d::ColorManager::getColor</a></div><div class="ttdeci">glm::vec4 getColor(const size_t i) const</div><div class="ttdoc">Return the i-th color.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:47</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html">pepr3d::ColorManager</a></div><div class="ttdoc">Represents a color palette, i.e., all colors and a selected active color.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:16</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_a81d621c28e948d1b3159dde1bcb73aea"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#a81d621c28e948d1b3159dde1bcb73aea">pepr3d::ColorManager::setActiveColorIndex</a></div><div class="ttdeci">void setActiveColorIndex(size_t index)</div><div class="ttdoc">Sets index of the currently selected / active color, safely checks boundaries.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:112</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_a3532df102b706a03bc0e23401c457e4f"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#a3532df102b706a03bc0e23401c457e4f">pepr3d::ColorManager::getActiveColorIndex</a></div><div class="ttdeci">size_t getActiveColorIndex() const</div><div class="ttdoc">Gets index of the currently selected / active color.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:107</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_ad6b9cb7395ea796012aec61e6292cdfd"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#ad6b9cb7395ea796012aec61e6292cdfd">pepr3d::ColorManager::mColorMap</a></div><div class="ttdeci">ColorMap mColorMap</div><div class="ttdoc">A vector containing all the colors that the application supports at this time.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:22</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_a136ee5ee62632d6537377fccdc5ef9c6"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#a136ee5ee62632d6537377fccdc5ef9c6">pepr3d::ColorManager::size</a></div><div class="ttdeci">size_t size() const</div><div class="ttdoc">Returns the number of currently used colors.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:53</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_a5ddc4ed221439f8b744b6d85b89127b3"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#a5ddc4ed221439f8b744b6d85b89127b3">pepr3d::ColorManager::addColor</a></div><div class="ttdeci">void addColor(const glm::vec4 newColor)</div><div class="ttdoc">Adds a new color if not above limit.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:68</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_a2393992e48c2c6715ac33cb067d3dc75"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#a2393992e48c2c6715ac33cb067d3dc75">pepr3d::ColorManager::replaceColors</a></div><div class="ttdeci">void replaceColors(const ColorMap &amp;newColors)</div><div class="ttdoc">Replace the current colors with this new vector of colors, trims if above limit.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:96</div></div>
<div class="ttc" id="classpepr3d_1_1_color_manager_html_add375baf3a503d79d4922dbd360b62af"><div class="ttname"><a href="classpepr3d_1_1_color_manager.html#add375baf3a503d79d4922dbd360b62af">pepr3d::ColorManager::replaceColors</a></div><div class="ttdeci">void replaceColors(const ColorMap::const_iterator start, const ColorMap::const_iterator end)</div><div class="ttdoc">Replace the current colors with this list, trims if above limit.</div><div class="ttdef"><b>Definition:</b> ColorManager.h:82</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_405fd32de3649961a5f009c7a3fe84df.html">geometry</a></li><li class="navelem"><b>ColorManager.h</b></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.15 </li>
  </ul>
</div>
</body>
</html>
